package com.zyp.shop.config;

import com.alibaba.druid.sql.visitor.functions.Concat;
import com.google.common.base.Predicates;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * Created by Intellij IDEA
 *
 * @author 赵雅璞
 * @Date: 2022/11/18 15:52
 * @Version 1.0
 */
@Configuration// 标记该类为配置类 等价于我们之前的.xml文件
public class SwaggerConfig {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("商城")
                .apiInfo(getInfo())
                .select()
                // 这个是 只要是 api/路径下的所有方法 都会生成 api说明
                //.paths(Predicates.and(PathSelectors.regex("/api/.*")))
                // 指定包下 都会生成 api说明
                .apis(RequestHandlerSelectors.basePackage("com.zyp.shop.controller")).build();
    }
    private ApiInfo getInfo() {
        Contact aaa = new Contact("赵雅璞", "www.baidu.com", "1474025894@qq.com");
        return new ApiInfo("在线Api","API","1.0","www.baidu.com",
                aaa,"文若科技","www.baidu.com", new ArrayList<>());
    }
}
